package cn.scm.server.multistage.base;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class ResultDTO<T> {
    @ApiModelProperty("响应码")
    private int code;
    @ApiModelProperty("响应信息")
    private String msg;
    @ApiModelProperty("返回数据")
    private T data;

    public static <E> ResultDTO<E> success() {
        ResultDTO<E> ret = new ResultDTO<>();
        ret.setCode(200);
        ret.setMsg("操作成功");
        ret.setData(null);
        return ret;
    }

    public static <E> ResultDTO<E> success(E e) {
        ResultDTO<E> ret = new ResultDTO<>();
        ret.setCode(200);
        ret.setMsg("操作成功");
        ret.setData(e);
        return ret;
    }

    public static <E> ResultDTO<E> fail(int code, String msg) {
        ResultDTO<E> ret = new ResultDTO<>();
        ret.setCode(code);
        ret.setMsg(msg);
        return ret;
    }
}
